<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="scenicSpotTicket"/>
    <#include "../common/header.ftl">
</head>
<body>
<#--门票的页面-->
<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">景点门票管理</h1>
                </div>
            </div>
        <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/scenicSpotTicket/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入景点名字/城市">
                </div>
                <button class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>所属景点</th>
                    <th>价格</th>
                    <th>有效期</th>
                    <th>种类</th>
                    <th>操作</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.scenicSpot.scenicSpotName}</td>
                        <td>${entity.price}</td>
                        <td>${(entity.date?string("yyyy-MM-dd"))!}</td>
                        <td>${entity.typeName}</td>
                        <td>

                            <a role="button" class="btn btn-info btn-xs inputBtn" data-json='${(entity.json)!}'>
                                <span class="glyphicon glyphicon-pencil"></span> 修改
                            </a>
                            <a role="button" class="btn btn-info btn-xs typeChangeBtn" data-json='${(entity.json)!}'>
                                <span class="glyphicon glyphicon-pencil"></span> 状态
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/scenicSpotTicket/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" name="id"/>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">所属景点</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="ScenicSpot.ScenicSpotName"/>
                            <input type="hidden" name="ScenicSpot.id"/>
                        </div>
                    </div>

                    <div class="form-group" >
                        <label class="col-lg-4 control-label">门票价格</label>
                        <div class="col-lg-6">
                            <input type="number" class="form-control" name="price"/>
                        </div>
                    </div>

                    <div class="form-group" >
                        <label class="col-lg-4 control-label">有效期</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="date" onclick="WdatePicker()"/>
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>
</div>


<div id="stateModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/scenicSpotTicket/changeState.do" method="post" id="StateForm">
                    <div class="form-group" >
                        <input type="hidden" name="id"/>
                        <label class="col-lg-4 control-label">状态</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="type">
                                <option value="0">下架</option>
                                <option value="1">正常</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary StateSubmit">保存</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {

        $(".inputBtn").click(function () {

            $("#editForm input").val("");
            var json = $(this).data("json");
            if (json) {
                $("#editForm input[name='id']").val(json.id);
                $("#editForm input[name='ScenicSpot.id']").val(json.ScenicSpotId);
                $("#editForm input[name='ScenicSpot.ScenicSpotName']").val(json.scenicSpotName).attr("disabled", true).css("background-color","#C0C0C0");
                $("#editForm input[name='price']").val(json.price);
                $("#editForm input[name='date']").val(json.date);
            }

            $("#inputModal").modal("show");
        });

        $(".submitBtn").click(function () {
            $("#editForm").submit();
        });

        $(".typeChangeBtn").click(function () {
            var json = $(this).data("json");
            $("#StateForm select[name='type']").val(json.type);
            $("#StateForm input[name='id']").val(json.id);
            $("#stateModal").modal("show");
        })
        $(".StateSubmit").click(function () {
            $("#StateForm").submit();
        })
    });
</script>
</body>
</html>